import { Entity, Column, PrimaryGeneratedColumn , OneToOne , ManyToOne , JoinColumn } from 'typeorm';
import { Teams } from './teams';
import { Season } from './season';
import { SeasonType } from './season_type';
import { Players } from './players';

export enum NBADataType {
    TEAM = "team", // 球队数据
    CURRENT = "current", // 当前赛事数据
    ALLSTAR = "allStar", // 全明星数据
    SEASON = "season", // 本赛季数据
    PLAYOFF = "playoff", // 季后赛赛季数据
    PLAYOFFCAREER = "career", // 季后赛生涯数据
    REGULACAREER = "regularCareer", // 常规赛生涯数据
    REGULAR = "regular", // 常规赛赛季数据
    GAMES = "games", // 本赛季每场数据
    SPLITS = "splits",// 分类数据
}

@Entity()
class NBAData {

    @PrimaryGeneratedColumn("uuid")
    id?: number;

    @Column({
        type: "double",
        comment: "场均助攻",
        nullable: true,
        default: 0
    })
    assistsPg: number;

    @Column({
        type: "double",
        comment: "场均盖帽",
        nullable: true,
        default: 0
    })
    blocksPg: number;

    @Column({
        type: "double",
        comment: "场均防守篮板",
        nullable: true,
        default: 0
    })
    defRebsPg: number;

    @Column({
        type: "double",
        comment: "效率值",
        nullable: true,
        default: 0
    })
    efficiency: number;

    @Column({
        type: "double",
        comment: "场均投篮次数",
        nullable: true,
        default: 0
    })
    fgaPg: number;

    @Column({
        type: "double",
        comment: "场均命中次数",
        nullable: true,
        default: 0
    })
    fgmPg: number;

    @Column({
        type: "double",
        comment: "投篮命中率",
        nullable: true,
        default: 0
    })
    fgpct: number;

    @Column({
        type: "double",
        comment: "场均犯规",
        nullable: true,
        default: 0
    })
    foulsPg: number;

    @Column({
        type: "double",
        comment: "场均罚球数",
        nullable: true,
        default: 0
    })
    ftaPg: number;

    @Column({
        type: "double",
        comment: "场均罚球命中数",
        nullable: true,
        default: 0
    })
    ftmPg: number;

    @Column({
        type: "double",
        comment: "罚球命中率",
        nullable: true,
        default: 0
    })
    ftpct: number;

    @Column({
        type: "double",
        comment: "登场场次",
        nullable: true,
        default: 0
    })
    games: number;

    @Column({
        type: "double",
        comment: "先发场次",
        nullable: true,
        default: 0
    })
    gamesStarted: number;

    @Column({
        type: "double",
        comment: "场均在场时长",
        nullable: true,
        default: 0
    })
    minsPg: number;

    @Column({
        type: "double",
        comment: "场均进攻篮板",
        nullable: true,
        default: 0
    })
    offRebsPg: number;

    @Column({
        type: "double",
        comment: "场均得分",
        nullable: true,
        default: 0
    })
    pointsPg: number;

    @Column({
        type: "double",
        comment: "场均篮板",
        nullable: true,
        default: 0
    })
    rebsPg: number;

    @Column({
        type: "double",
        comment: "场均抢断",
        nullable: true,
        default: 0
    })
    stealsPg: number;

    @Column({
        type: "double",
        comment: "场均三分投篮次数",
        nullable: true,
        default: 0
    })
    tpaPg: number;

    @Column({
        type: "double",
        comment: "场均三分投篮命中次数",
        nullable: true,
        default: 0
    })
    tpmPg: number;

    @Column({
        type: "double",
        comment: "三分命中率",
        nullable: true,
        default: 0
    })
    tppct: number;

    @Column({
        type: "double",
        comment: "场均失误",
        nullable: true,
        default: 0
    })
    turnoversPg: number;

    @Column({
        type: "double",
        comment: "总助攻数",
        nullable: true,
        default: 0
    })
    assists: number;

    @Column({
        type: "double",
        comment: "总盖帽数",
        nullable: true,
        default: 0
    })
    blocks: number;

    @Column({
        type: "double",
        comment: "总防守篮板数",
        nullable: true,
        default: 0
    })
    defRebs: number;

    @Column({
        type: "double",
        comment: "总投篮数",
        nullable: true,
        default: 0
    })
    fga: number;

    @Column({
        type: "double",
        comment: "总命中投篮数",
        nullable: true,
        default: 0
    })
    fgm: number;

    @Column({
        type: "double",
        comment: "总犯规数",
        nullable: true,
        default: 0
    })
    fouls: number;

    @Column({
        type: "double",
        comment: "总罚篮数",
        nullable: true,
        default: 0
    })
    fta: number;

    @Column({
        type: "double",
        comment: "总命中罚篮数",
        nullable: true,
        default: 0
    })
    ftm: number;

    @Column({
        type: "double",
        comment: "总上场时间",
        nullable: true,
        default: 0
    })
    mins: number;

    @Column({
        type: "double",
        comment: "总进攻篮板",
        nullable: true,
        default: 0
    })
    offRebs: number;

    @Column({
        type: "double",
        comment: "总得分",
        nullable: true,
        default: 0
    })
    points: number;

    @Column({
        type: "double",
        comment: "总篮板",
        nullable: true,
        default: 0
    })
    rebs: number;

    @Column({
        type: "double",
        comment: "不知道啥意思",
        nullable: true,
        default: 0
    })
    secs: number;

    @Column({
        type: "double",
        comment: "总抢断",
        nullable: true,
        default: 0
    })
    steals: number;

    @Column({
        type: "double",
        comment: "总三分投篮次数",
        nullable: true,
        default: 0
    })
    tpa: number;

    @Column({
        type: "double",
        comment: "总三分命中投篮次数",
        nullable: true,
        default: 0
    })
    tpm: number;

    @Column({
        type: "double",
        comment: "总失误数",
        nullable: true,
        default: 0
    })
    turnovers: number;
    /**
     * 如果是每场比赛数据，会有如下字段  start
     * gameId 这个目前网站上面没有找到明确的比赛接口，所以只是记录，没有创建详细的比赛表
     */
    @Column({
        type: "varchar",
        length: 255,
        comment: "比赛id",
        nullable: true,
        default: ""
    })
    gameId?: string;

    @Column({
        type: "varchar",
        length: 255,
        comment: "是否主场",
        nullable: true,
        default: ""
    })
    isHome?: string;

    @Column({
        type: "varchar",
        length: 255,
        comment: "胜负",
        nullable: true,
        default: ""
    })
    winOrLoss?: string;

    @Column({
        type: "int",
        comment: "对手总得分",
        nullable: true,
        default: 0
    })
    oppTeamScore?: number;

    @Column({
        type: "int",
        comment: "总得分",
        nullable: true,
        default: 0
    })
    teamScore?: number;

    @Column({
        type: "varchar",
        comment: "比赛时间",
        nullable: true,
        default: ""
    })
    utcMillis?: string;
    /**
     * end
     */

    @Column({
        type: "varchar",
        comment: "分类数据名称",
        nullable: true,
        default: ""
    })
    splitName?: string;

    @Column({
        type: "varchar",
        comment: "分类数据展示名称",
        nullable: true,
        default: ""
    })
    splitDisplayName?: string;

    @Column({
        type: "enum",
        enum: NBADataType,
        default: NBADataType.GAMES
    })
    dataType: string;

    // 除了球队数据类型，其余类型都应该有关联球员
    @ManyToOne(type => Players)
    players?: Players;

    // 所有数据类型都应该有关联球队
    @ManyToOne(type => Teams)
    teams?: Teams;

    // 所有数据类型都应该有关联球队
    // 打出数据时，所在的球队
    @ManyToOne(type => Teams)
    rightAwayTeam?: Teams;

    /**
     * 如果是每场比赛数据，会有对手球队字段  start
     */
    @ManyToOne(type => Teams)
    oppTeams?: Teams;
    /**
     * end
     */
    // 除了生涯数据，其余所有数据都应该有关联具体某个赛季
    // @ManyToOne(type => Season, season => season.id)
    // season: Season;
    @ManyToOne(type => Season)
    season?: Season;

    // 只有部分类型数据会区分是常规赛还是季后赛 （不知道为什么，全员接口并没有季前赛数据，暂时先不管，只做预留）
    // @ManyToOne(type => SeasonType, seasonType => seasonType.id)
    // seasonType: SeasonType;
    @ManyToOne(type => SeasonType)
    seasonType?: SeasonType;

}

export { NBAData };